import 'package:gameplay_flutter/generated/json/base/json_convert_content.dart';
import 'package:gameplay_flutter/lib_basemodel/popularity/popularity_model.dart';

PopularityModel $PopularityModelFromJson(Map<String, dynamic> json) {
  final PopularityModel popularityModel = PopularityModel();
  final String? iconUrl = jsonConvert.convert<String>(json['iconUrl']);
  if (iconUrl != null) {
    popularityModel.iconUrl = iconUrl;
  }
  final String? backgroundColor =
      jsonConvert.convert<String>(json['backgroundColor']);
  if (backgroundColor != null) {
    popularityModel.backgroundColor = backgroundColor;
  }
  final String? levelName = jsonConvert.convert<String>(json['levelName']);
  if (levelName != null) {
    popularityModel.levelName = levelName;
  }
  final int? levelCode = jsonConvert.convert<int>(json['levelCode']);
  if (levelCode != null) {
    popularityModel.levelCode = levelCode;
  }
  final int? hotValue = jsonConvert.convert<int>(json['hotValue']);
  if (hotValue != null) {
    popularityModel.hotValue = hotValue;
  }
  final bool? isInvalid = jsonConvert.convert<bool>(json['isInvalid']);
  if (isInvalid != null) {
    popularityModel.isInvalid = isInvalid;
  }
  final bool? isNoName = jsonConvert.convert<bool>(json['isNoName']);
  if (isNoName != null) {
    popularityModel.isNoName = isNoName;
  }
  final String? groupName = jsonConvert.convert<String>(json['groupName']);
  if (groupName != null) {
    popularityModel.groupName = groupName;
  }
  final int? wealthValue = jsonConvert.convert<int>(json['wealthValue']);
  if (wealthValue != null) {
    popularityModel.wealthValue = wealthValue;
  }
  final bool? isShowWealthName =
      jsonConvert.convert<bool>(json['isShowWealthName']);
  if (isShowWealthName != null) {
    popularityModel.isShowWealthName = isShowWealthName;
  }
  return popularityModel;
}

Map<String, dynamic> $PopularityModelToJson(PopularityModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['iconUrl'] = entity.iconUrl;
  data['backgroundColor'] = entity.backgroundColor;
  data['levelName'] = entity.levelName;
  data['levelCode'] = entity.levelCode;
  data['hotValue'] = entity.hotValue;
  data['isInvalid'] = entity.isInvalid;
  data['isNoName'] = entity.isNoName;
  data['groupName'] = entity.groupName;
  data['wealthValue'] = entity.wealthValue;
  data['isShowWealthName'] = entity.isShowWealthName;
  return data;
}

extension PopularityModelExtension on PopularityModel {
  PopularityModel copyWith({
    String? iconUrl,
    String? backgroundColor,
    String? levelName,
    int? levelCode,
    int? hotValue,
    bool? isInvalid,
    bool? isNoName,
    String? groupName,
    int? wealthValue,
    bool? isShowWealthName,
  }) {
    return PopularityModel()
      ..iconUrl = iconUrl ?? this.iconUrl
      ..backgroundColor = backgroundColor ?? this.backgroundColor
      ..levelName = levelName ?? this.levelName
      ..levelCode = levelCode ?? this.levelCode
      ..hotValue = hotValue ?? this.hotValue
      ..isInvalid = isInvalid ?? this.isInvalid
      ..isNoName = isNoName ?? this.isNoName
      ..groupName = groupName ?? this.groupName
      ..wealthValue = wealthValue ?? this.wealthValue
      ..isShowWealthName = isShowWealthName ?? this.isShowWealthName;
  }
}
